<template>
  <div class="home">
    <el-card class="login-box">
      <el-form
        :model="loginForm"
        ref="form"
        :rules="rules"
        label-width="80px"
        :inline="false"
        size="normal"
      >
        <el-form-item label="用户名" prop="userName">
          <el-input v-model="loginForm.userName"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="loginForm.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import Qs from 'qs'

export default {
  name: 'Home',
  components: {
    HelloWorld
  },
  data() {
    return {
      loginForm: {
        userName: '',
        password: ''
      },
      rules: {
        userName: [{ requier: true, message: '请输入用户名', trigger: 'blur' }]
      }
    }
  },
  mounted() {
    this.$http
      .get('login')
      .then(res => {
        console.log(res)
        console.log(res.headers.date)
      })
      .catch(err => {
        console.log(222222)
        console.log({ err })
      })
  },
  methods: {
    changeParams(value) {
      this.url.parse = Qs.parse(value.split('?')[1])
    },
    onSubmit() {
      console.log(11)
    }
  }
}
</script>

<style lang="less" scoped>
.login-box {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: 40%;
  max-width: 500px;
}
</style>
